package com.example.demo13.service.impl;

import com.example.demo13.mapper.DialogMapper;
import com.example.demo13.model.Dialog;
import com.example.demo13.service.DialogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DialogServiceImpl implements DialogService {
    @Autowired
    private DialogMapper dialogMapper;
    @Override
    public Dialog queryDialogById(Integer id) {
        return dialogMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateDialogById(Dialog dialog) {
        int i=dialogMapper.updateByPrimaryKeySelective(dialog);
        return i;
    }

    @Override
    public String deleteDialogById(Integer id) {
       int i=dialogMapper.deleteByPrimaryKey(id);
       if(i==0){
           return id+"删除失败";
       }else{
           return id+"删除陈宫";
       }
    }

    @Override
    public int insertDialog(Dialog dialog) {
        return dialogMapper.insertSelective(dialog);
    }

}
